<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/inc/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色信息列表</title>
<%@ include file="/inc/head.jsp"%>
<script type="text/javascript">
	var grid;
	$(function() {
		grid = $('#grid')
				.datagrid(
						{
							title : '',
							url : '${ctx}/sys/permission/role',
							striped : true,
							rownumbers : true,
							pagination : true,
							idField : 'id',
							sortName : 'createDate',
							sortOrder : 'desc',
							pageSize : 50,
							pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
									400, 500 ],
							frozenColumns : [ [ {
								field : 'id',
								checkbox : true
							}, {
								width : '100',
								title : '角色名称',
								field : 'name',
								sortable : true
							}, {
								width : '200',
								title : '角色标识',
								field : 'role',
								sortable : true
							}, {
								width : '300',
								title : '详细描述',
								field : 'description',
								sortable : true
							} ] ],
							columns : [ [
									{
										width : '80',
										title : '状态',
										field : 'show',
										sortable : true,
										formatter : function(value) {
											if (value) {
												return '可用';
											} else {
												return "不可用";
											}
										}
									},
									{
										title : '操作',
										field : 'action',
										width : '90',
										formatter : function(value, row) {
											var str = '';
											str += sy
													.formatString(
															'<img class="iconImg ext-icon-note" title="查看" onclick="permission.view(\'{0}\');"/>',
															row.id);
											str += sy
													.formatString(
															'<img class="iconImg ext-icon-note_edit" title="编辑" onclick="permission.edit(\'{0}\');"/>',
															row.id);
											str += sy
													.formatString(
															'<img class="iconImg ext-icon-note_delete" title="删除" onclick="permission.del(\'{0}\');"/>',
															row.id);
											return str;
										}
									} ] ],
							toolbar : '#toolbar',
							onBeforeLoad : function(param) {
								parent.$.messager.progress({
									text : '数据加载中....'
								});
							},
							onLoadSuccess : function(data) {
								$('.iconImg').attr('src', sy.pixel_0);
								parent.$.messager.progress('close');
							}
						});
		permission = {
			create : function() {
				var dialog = sy.modalDialog({
							title : '添加角色信息',
							url : sy.contextPath+ '/sys/permission/role/create',
							buttons : [
									{
										text : '保存',
										handler : function() {
											dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid,
															parent.$);
										}
									} ]
						});
			},
			view : function() {
				var dialog = sy.modalDialog({
					title : '查看角色信息',
					url : sy.contextPath + '/sys/permission/role/view/'
							+ id
				});
			},
			del : function(id) {
				parent.$.messager.confirm('询问', '您确定要删除此记录？', function(r) {
					var url = "${ctx}/sys/permission/role/" + id
							+ "/delete";
					if (r) {
						$.post(url, function() {
							grid.datagrid('reload');
						}, 'json');
					}
				});
			},
			edit : function(id) {
				var url = "${ctx}/sys/permission/role/update/" + id ;
				var dialog = sy.modalDialog({
					title : '编辑权限信息',
					url : url,
					buttons : [ {
						text : '编辑',
						handler : function() {
							dialog.find('iframe').get(0).contentWindow
									.submitForm(dialog, grid, parent.$);
						}
					} ]
				});

			}
		};
	});
</script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div id="toolbar" style="display: none;">
		<div style="padding: 0 0 0 7px; color: #333;">
			<form id="searchForm">
				<table>
					<tr>
						<td>角色名称</td>
						<td><input name="search.name_like" style="width: 80px;" /></td>
						<td>角色标识</td>
						<td><input name="search.role_like" style="width: 80px;" /></td>
						<td><a href="javascript:void(0);" class="easyui-linkbutton"
							data-options="iconCls:'ext-icon-zoom',plain:true"
							onclick="grid.datagrid('load',sy.serializeObject($('#searchForm')));">过滤</a><a
							href="javascript:void(0);" class="easyui-linkbutton"
							data-options="iconCls:'ext-icon-zoom_out',plain:true"
							onclick="$('#searchForm input').val('');grid.datagrid('load',{});">重置过滤</a></td>
					</tr>
				</table>
			</form>
		</div>
		<div>
			<a href="javascript:void(0);" class="easyui-linkbutton"
				data-options="iconCls:'ext-icon-note_add',plain:true"
				onclick="permission.create();">添加</a>
		</div>
	</div>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid" data-options="fit:true,border:false"></table>
	</div>
</body>
</html>